import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    { path: '/', redirect: '/user' },
    { path: '/login', component: () => import('@/views/newLogin.vue') },
    {
      path: '/manager',
      component: () => import('@/views/Manager.vue'),
      redirect: '/manager/home',
      children: [
        { path: '/manager/person', component: () => import('@/views/manager/Person.vue') },
        { path: '/manager/password', component: () => import('@/views/manager/Password.vue') },
        { path: '/manager/home', component: () => import('@/views/manager/Home.vue') },
        { path: '/manager/admin', component: () => import('@/views/manager/Admin.vue') },
        { path: '/manager/user', component: () => import('@/views/manager/User.vue') },
        { path: '/manager/farmer', component: () => import('@/views/manager/Farmer.vue') },
        { path: '/manager/notice', component: () => import('@/views/manager/Notice.vue') },
        { path: '/manager/im', name: 'managerIm', component: () => import('@/views/manager/Im.vue') },
        { path: '/manager/room', component: () => import('@/views/manager/Room.vue') }
      ]
    },
    {
      path: '/farmer',
      component: () => import('@/views/Farmer.vue'),
      redirect: '/farmer/home',
      children: [
        { path: '/farmer/person', component: () => import('@/views/farmer/Person.vue') },
        { path: '/farmer/password', component: () => import('@/views/farmer/Password.vue') },
        { path: '/farmer/home', component: () => import('@/views/farmer/Home.vue') },
        { path: '/farmer/item', component: () => import('@/views/farmer/Item.vue') },
        { path: '/farmer/im', name: 'farmerIm', component: () => import('@/views/farmer/Im.vue') },
        { path: '/farmer/room', component: () => import('@/views/farmer/Room.vue') }
      ]
    },
    {
      path: '/user',
      component: () => import('@/views/User.vue')
    },
    { path: '/register', component: () => import('@/views/newRegister.vue') },
    { path: '/chatroom', name: 'chatroom', component: () => import('@/views/user/Chat.vue') },
    { path: '/retail', name: 'retail', component: () => import('@/views/user/Retail.vue') },
    { path: '/retailSub', component: () => import('@/views/user/RetailSubPost.vue') },
    {path:'/retailNews',component:()=>import('@/views/user/RetailNews.vue')},
    {path:'/retailMy',component:()=>import('@/views/user/RetailMy.vue')},
    { path: '/fruitCentre', component: () => import('@/views/user/FruitCentre.vue') },
    {
      path: '/f/:categoryId?', name: "fruitCentre",
      component: () => import('@/views/user/FruitCentre.vue'), props: true
    },
    { path: '/fruitMarket', component: () => import('@/views/user/FruitMarket.vue') },
    { path: '/ziziFarm', component: () => import('@/views/user/ZiziFarm.vue') },
    { path: '/ziziNews', component: () => import('@/views/user/ZiziNews.vue') },
    {
      path: '/news/:id', name: 'newsDetail',
      component: () => import('@/views/user/NewsDetail.vue'), props: true
    },
    { path: '/myself', component: () => import('@/views/user/MySelf.vue') },
    { path: '/myorder', component: () => import('@/views/user/MyOrder.vue') },
    { path: '/mycart', component: () => import('@/views/user/MyCart.vue') },
    { path: '/myfav', component: () => import('@/views/user/MyFav.vue') },
    { path: '/orderSubmit/:itemId&:buyNum', component: () => import('@/views/user/OrderSubmit.vue') },
    { path: '/pay/:trackingNumber', component: () => import('@/views/user/Pay.vue') },
    { path: '/roomdesc/:roomId', component: () => import('@/views/user/RoomDesc.vue') },
    {
      path: '/desc/:itemId', // 添加动态参数
      component: () => import('@/views/user/ItemDesc.vue')
    },
    {path:'/qr/:qrCode',component:()=>import('@/views/user/QR.vue')},
    {path:'/ziziSeek',component:()=>import('@/views/user/ZiziSeek.vue')},
    {path:'/calGaokao',component:()=>import('@/views/tools/cal.vue')},
  ]
})

export default router
